<template>
  <div class="header">
    <div class="header-return" v-show="showHeader">
      <span class="border-return"></span>
      <router-link to="/">
        <span class="iconfont return">&#xe8a4; </span>
      </router-link>
    </div>
    <div class="header-top" v-show="!showHeader" :style="styleOpacity">
      <div class="header-left">
        <router-link to="/">
          <span class="iconfont"> &#xe8a4; </span>
        </router-link>
      </div>
      北京鲜花港
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      showHeader: true,
      styleOpacity: {
        opacity: 0,
      },
    };
  },
  mounted() {
    let That = this;
    window.addEventListener("scroll", function () {
      let top = this.document.documentElement.scrollTop;
      if (top > 45) {
        let opacity = top / 130;
        opacity = opacity > 1 ? 1 : opacity;
        That.styleOpacity = { opacity };
        That.showHeader = false;
      } else {
        That.showHeader = true;
      }
    });
  },
};
</script>
<style scoped lang="stylus">
@import '~@/assets/css/var.styl'
.header-return {
  position: absolute;
  left: 0.2rem;
  top: 0.1rem;
  width: 0.72rem;
  height: 0.72rem;
}
.border-return {
  display: block;
  background: #000;
  width: 0.72rem;
  height: 0.72rem;
  opacity: 0.5;
  border-radius: 0.36rem;
}
.return {
  position: absolute;
  left: -0.05rem;
  top: 0;
  color: #fff;
  width: 0.72rem;
  line-height: 0.72rem;
  text-align: left;
  text-indent: 0.24rem;
  font-size: 0.32rem;
  font-weight: bold;
}
.header-top {
  position: fixed;
  top:0;
  width: 100%;
  text-align: center;
  line-height: 0.88rem;
  background: $bgColor;
  color: $textColor;
  font-size: 0.36rem;

}
.header-left {
  position: absolute;
  width: 0.4rem;
  padding: 0 0.2rem;
  text-align: center;
  font-weight: bold;
}
.header-left a{
  color: #fff
}
</style>
